All files / src/routes/workout/[id]/_components ExerciseList.svelte

0% Statements 0/7
100% Branches 0/0
0% Functions 0/3
0% Lines 0/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                                                                 
<script lang="ts">
	import PrescribedExerciseCard from './PrescribedExerciseCard.svelte';
	import type { PrescribedExerciseView, SetLogView } from '../+page.server';
	import type { Enums } from '@strengthsys/shared';
 
	// Single source of truth is the DB `workout_status` enum (via @strengthsys/shared);
	// values propagate through `gen:types`, so this never needs hand-editing on enum change.
	type WorkoutStatus = Enums<'workout_status'>;
 
	interface Props {
		exercises: PrescribedExerciseView[];
		status: WorkoutStatus;
		workoutLogId: string | null;
		setLogs: SetLogView[];
	}
 
	let { exercises, status, workoutLogId, setLogs }: Props = $props();
</script>
 
<ol data-testid="workout-detail-exercise-list" class="exercise-list">
	{#each exercises as exercise (exercise.id)}
		{@const loggedSetMap = new Map(
			setLogs
				.filter((s) => s.prescribed_exercise_id === exercise.id)
				.map((s) => [s.set_number, s] as const),
		)}
		<li data-testid="workout-detail-exercise" class="exercise-list__item">
			<PrescribedExerciseCard
				{exercise}
				{status}
				{workoutLogId}
				{loggedSetMap}
			/>
		</li>
	{/each}
</ol>
 
<style>
	.exercise-list {
		list-style: none;
		padding: 0;
		margin: 0;
		display: flex;
		flex-direction: column;
		gap: var(--space-4);
	}
 
</style>